package scope

import "gorm.io/gorm"

const OperatorKey = "operator"

type IOperator interface {
	GetUserId() any
}

func WithOperator(operator IOperator) Operator {
	return Operator{
		UserId: operator.GetUserId(),
	}
}

type Operator struct {
	UserId any
}

func (o Operator) MakeScope() Scope {
	return func(db *gorm.DB) *gorm.DB {
		return db.Set(OperatorKey, o.UserId)
	}
}
